/*
 * Copyright (c) 2008 Openviewing
 *
 * Permission is hereby granted, free of charge, to any person
 * obtaining a copy of this software and associated documentation
 * files (the "Software"), to deal in the Software without
 * restriction, including without limitation the rights to use,
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following
 * conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 * 
 * Eclipse created: Aug 19, 2008
 */
package org.openviewing.foundation.control.domain;

import java.util.List;

/** Generic management strategy. */
public interface Management<T, PK>
{
    /** Generic creation operation.
     * 
     * @param instance The instance of the object to create.
     * @return The updated created object.
     * @throws Exception Instance is invalid or unable to be persisted.
     */
    public T create(T instance) throws Exception;
    /** Generic read operation.
     * 
     * @param identifier The object instance to retrieved for the given value.
     * @return The instance of the object.
     */
    public T read(PK identifier);
    /** Generic read all operation.
     * 
     * @return A set of object instances.
     */
    public List<T> read();
    /** Generic update operation.
     * 
     * @param instance The object instance to be updated.
     * @return The updated object.
     * @throws Exception Instance is invalid or unable to be persisted.
     */
    public T update(T instance) throws Exception;
    /** Generic delete operation.
     * 
     * @param instance The object instance to be deleted.
     */
    public T delete(PK identifier);
}
